places view: Avoid a crash in finalize
authorMatthias Clasen <mclasen@redhat.com>
Wed, 2 Sep 2015 05:50:51 +0000 (01:50 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Wed, 2 Sep 2015 11:15:57 +0000 (07:15 -0400)
When the places view is finalized before the network loading
is finished, the async operation is cancelled, and the callback
accesses the places view while it is already in a state of
disrepair. Avoid that access.

gtk/gtkplacesview.c

index a2a8395a47254e534f4af158e15d6df39247768e..5fa3c39efa226668a22c417385620eb6c4fe4dc3 100644 (file)
@@ -992,11 +992,8 @@ network_enumeration_finished (GObject      *source_object,
 {
   GtkPlacesViewPrivate *priv;
   GFileEnumerator *enumerator;
-  GtkPlacesView *view;
   GError *error;
 
-  view = GTK_PLACES_VIEW (user_data);
-  priv = gtk_places_view_get_instance_private (view);
   error = NULL;
   enumerator = g_file_enumerate_children_finish (G_FILE (source_object), res, &error);
 
@@ -1010,6 +1007,7 @@ network_enumeration_finished (GObject      *source_object,
     }
   else
     {
+      priv = gtk_places_view_get_instance_private (GTK_PLACES_VIEW (user_data));
       g_file_enumerator_next_files_async (enumerator,
                                           G_MAXINT32,
                                           G_PRIORITY_DEFAULT,